package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/")
public class RPCController {
    @Autowired
    private RpcClientProxy proxy;

    @RequestMapping("findById")
    public User findById(Integer id){
        IUserService userService = (IUserService) proxy.createProxy(IUserService.class);
        return userService.getById(id);
    }

    @RequestMapping("findList")
    public List<User> findList(){
        IUserService userService = (IUserService) proxy.createProxy(IUserService.class);
        return userService.findList();
    }
}
